using System;
using System.Text;
using System.ComponentModel;
using System.Configuration;

using System.Xml.Linq;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace SharpPopulatorLib
{

	public static class Settings
    {

        #region Atributes

        private static String _Provider;
        private static String _Server;
        private static String _DBInstance;
        private static String _User;
        private static String _UserPwd;

        #endregion

        #region Properties

        [Category("Connection"), Description("")]
        public static String Provider
		{
			get { return _Provider; }
			set { _Provider = value; }
		}

        [Category("Connection"), Description("")]
		public static String Server
		{
            get { return _Server; }
            set { _Server = value; }
		}

        [Category("Connection"), Description("")]
		public static String DBInstance
		{
            get { return _DBInstance; }
            set { _DBInstance = value; }
		}

        [Category("Connection"), Description("")]
		public static String User
		{
            get { return _User; }
            set { _User = value; }
		}

        [Category("Connection"), Description("")]
		public static String UserPassword
		{
            get { return _UserPwd; }
            set { _UserPwd = value; }
		}

        [Category("Connection"), Description("")]
		public static String ConnectionString
		{
			get
            { return String.Format(ConfigurationManager.AppSettings["MSSQLConnection"], _Server, _DBInstance, _User, _UserPwd); }
		}

        #endregion

        #region Private methods



        #endregion

        #region Public methods

        public static List<String> GetProviders()
        { 
            //
            List<String> _Providers = new List<String>();
            XDocument doc = Utils.XMLDocumentLoader();

            if (doc != null)
            {
                _Providers = (from xnode in doc.Element("Providers").Elements("Provider")
                             select xnode.Element("Name").Value).ToList();
            }

            return _Providers;
        }

        #endregion

    }

}
